import myfetch from './util';

myfetch.defaultBaseURL = 'manage';

export default {
	adminLogin(adminInfo) {
		return myfetch.post('user/login.do', {
			data: adminInfo
		})
	},
	getBaseCount() {
		return myfetch.get('statistic/base_count.do')
	},
	getProductList(pageNum) {
		pageNum = pageNum || 1;
		return myfetch.get('product/list.do', {
			params: {
				pageNum
			}
		})
	},
	getProductCategoryList(categoryId) {
		categoryId = categoryId || 0;
		return myfetch.get('category/get_category.do', {
			params: {
				categoryId
			}
		})
	},
	searchProductList(params) {
		return myfetch.get('product/search.do', {
			params
		})
	},
	soldOut(id) {
		return myfetch.get('product/set_sale_status.do', {
			params: {
				productId: id,
				status: 2
			}
		})
	},
	putaway(id) {
		return myfetch.get('product/set_sale_status.do', {
			params: {
				productId: id,
				status: 1
			}
		})
	},
	saveUpload(form) {
		return myfetch.form('product/upload.do', {
			data: form
		})
	},
	editorImgUpload(form) {
		return myfetch.form('product/richtext_img_upload.do', {
			data: form
		})
	},
	saveProduct(data) {
		return myfetch.get('product/save.do', {
			params: data
		})
	},
	getProductDetail(id) {
		return myfetch.get('product/detail.do', {
			params: {
				productId: id
			}
		})
	},
	setCategoryName(params) {
		return myfetch.get('category/set_category_name.do', {
			params
		})
	},
	addCategory(params) {
		return myfetch.get('category/add_category.do', {
			params
		})
	},
	getUserList(pageNum) {
		return myfetch.post('user/list.do', {
			data: {
				pageNum
			}
		})
	},
	getOrderList(pageNum) {
		return myfetch.get('order/list.do', {
			params: {
				pageNum
			}
		})
	},
	searchOrderList(params) {
		return myfetch.get('order/search.do', {
			params
		})
	},
	getOrderDetail(orderNo) {
		return myfetch.get('order/detail.do', {
			params: {
				orderNo
			}
		})
	}
}